import { EnumSchema } from '@/utils/common/types';
import { PresetColorEnum } from '@/enums/colorEnum';
import { useI18n } from '@/hooks/web/useI18n';

/** 性别枚举 */
export enum GenderEnum {
  /** 未知 */
  Unknown = 0,
  /** 男 */
  Male = 1,
  /** 女 */
  Female = 2,
}

/** 性别实体 */
export class GenderEntity {
  /** 性别 */
  Gender: GenderEnum;
  /** 显示描述 */
  Display: string;
  /** 颜色 */
  Color?: PresetColorEnum | string;

  constructor(gender: GenderEnum, color?: PresetColorEnum | string) {
    const { t } = useI18n();
    this.Gender = gender;
    this.Color = color;
    switch (gender) {
      case GenderEnum.Unknown:
        // this.Display = '未知';
        this.Display = t('enum.gender.unknown');
        this.Color = this.Color ? this.Color : PresetColorEnum.Default;
        break;
      case GenderEnum.Male:
        // this.Display = '男';
        this.Display = t('enum.gender.male');
        this.Color = this.Color ? this.Color : PresetColorEnum.Blue;
        break;
      case GenderEnum.Female:
        // this.Display = '女';
        this.Display = t('enum.gender.female');
        this.Color = this.Color ? this.Color : PresetColorEnum.Magenta;
        break;
    }
  }
}

//#region 获取性别枚举架构
/**
 * 获取性别枚举架构
 */
export function getGenderEnumSchema(enableTag = true): EnumSchema[] {
  const enumSchema: EnumSchema[] = [];
  const entities: GenderEntity[] = [
    new GenderEntity(GenderEnum.Unknown),
    new GenderEntity(GenderEnum.Male),
    new GenderEntity(GenderEnum.Female),
  ];
  entities.forEach((item) => {
    enumSchema.push({
      key: item.Gender as number,
      label: item.Display,
      value: item.Gender as number,
      tag: enableTag,
      tagColor: item.Color,
    });
  });
  return enumSchema;
}
//#endregion
